ANS Forth Core words

I: Interpretation semantics
C: Compilation semantics
R: Run-time semantics
S: Initiation semantics
N: Notes

!
    ( x a-addr -- )
    Store x at a-addr.

#
    ( ud1 -- ud2 )
    Divide ud1 by the number in BASE giving the
    quotient ud2 and the remainder n.  (n is the
    least-significant digit of ud1.) Convert n to
    external form and add the resulting character
    to the beginning of the pictured numeric
    output string.  An ambiguous condition exists
    if # executes outside of a <# #> delimited
    number conversion.

#>
    ( xd -- c-addr u )
    Drop xd.  Make the pictured numeric output
    string available as a character string. 
    c-addr and u specify the resulting character
    string. A program may replace characters
    within the string.

#S
    ( ud1 -- ud2 )
    Convert one digit of ud1 according to the rule
    for #.  Continue conversion until the quotient
    is zero.  ud2 is zero.  An ambiguous condition
    exists if #S executes outside of a <# #>
    delimited number conversion.

'
    ( "<spaces>name" -- xt )
    Skip leading space delimiters.  Parse name
    delimited by a space. Find name and return xt,
    the execution token for name.  An ambiguous
    condition exists if name is not found. When
    interpreting, ' xyz EXECUTE is equivalent to
    xyz.

(
 C: Perform the execution semantics given below.
 E: ( "ccc<paren>" -- )
    Parse ccc delimited by ) (right parenthesis). 
    ( is an immediate word. The number of
    characters in ccc may be zero to the number of
    characters in the parse area.

*
    ( n1|u1 n2|u2 -- n3|u3 )
    Multiply n1|u1 by n2|u2 giving the product
    n3|u3.

*/
    ( n1 n2 n3 -- n4 )
    Multiply n1 by n2 producing the intermediate
    double-cell result d. Divide d by n3 giving
    the single-cell quotient n4.  An ambiguous
    condition exists if n3 is zero or if the
    quotient n4 lies outside the range of a signed
    number.  If d and n3 differ in sign, the
    implementation-defined result returned will be
    the same as that returned by either the phrase
    >R M* R> FM/MOD SWAP DROP or the phrase >R M*
    R> SM/REM SWAP DROP.

*/MOD
    ( n1 n2 n3 -- n4 n5 )
    Multiply n1 by n2 producing the intermediate
    double-cell result d. Divide d by n3 producing
    the single-cell remainder n4 and the single-
    cell quotient n5.  An ambiguous condition
    exists if n3 is zero, or if the quotient n5
    lies outside the range of a single-cell signed
    integer. If d and n3 differ in sign, the
    implementation-defined result returned will be
    the same as that returned by either the phrase
    >R M* R> FM/MOD or the phrase >R M* R> SM/REM.

+
    ( n1|u1 n2|u2 -- n3|u3 )
    Add n2|u2 to n1|u1, giving the sum n3|u3.

+!
    ( n|u a-addr -- )
    Add n|u to the single-cell number at a-addr.

+LOOP
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: do-sys -- )
    Append the run-time semantics given below to
    the current definition. Resolve the
    destination of all unresolved occurrences of
    LEAVE between the location given by do-sys and
    the next location for a transfer of control,
    to execute the words following +LOOP.
 R: ( n -- ) ( R: loop-sys1 -- | loop-sys2 )
    An ambiguous condition exists if the loop
    control parameters are unavailable.  Add n to
    the loop index.  If the loop index did not
    cross the boundary between the loop limit
    minus one and the loop limit, continue
    execution at the beginning of the loop. 
    Otherwise, discard the current loop control
    parameters and continue execution immediately
    following the loop.

,
    ( x -- )
    Reserve one cell of data space and store x in
    the cell.  If the data- space pointer is
    aligned when , begins execution, it will
    remain aligned when , finishes execution.  An
    ambiguous condition exists if the data- space
    pointer is not aligned prior to execution of
    ,.

-
    ( n1|u1 n2|u2 -- n3|u3 )
    Subtract n2|u2 from n1|u1, giving the 
    difference n3|u3.

.
    ( n -- )
    Display n in free field format.

.
 I: Interpretation semantics for this word are 
    undefined.
 C: ( "ccc<quote>" -- )
    Parse ccc delimited by " (double-quote). 
    Append the run-time semantics given below to
    the current definition.
 R: ( -- )
    Display ccc.

/
    ( n1 n2 -- n3 )
    Divide n1 by n2, giving the single-cell
    quotient n3.  An ambiguous condition exists if
    n2 is zero.  If n1 and n2 differ in sign, the
    implementation-defined result returned will be
    the same as that returned by either the phrase
    >R S>D R> FM/MOD SWAP DROP or the phrase >R
    S>D R> SM/REM SWAP DROP.

/MOD
    ( n1 n2 -- n3 n4 )
    Divide n1 by n2, giving the single-cell
    remainder n3 and the single-cell quotient n4. 
    An ambiguous condition exists if n2 is zero.
    If n1 and n2 differ in sign, the
    implementation-defined result returned will be
    the same as that returned by either the phrase
    >R S>D R> FM/MOD or the phrase >R S>D R>
    SM/REM.

0<
    ( n -- flag )
    flag is true if and only if n is less than
    zero.

0=
    ( x -- flag )
    flag is true if and only if x is equal to zero.

1+
    ( n1|u1 -- n2|u2 )
    Add one (1) to n1|u1 giving the sum n2|u2.

1-
    ( n1|u1 -- n2|u2 )
    Subtract one (1) from n1|u1 giving the 
    difference n2|u2.

2!
    ( x1 x2 a-addr -- )
    Store the cell pair x1 x2 at a-addr, with x2
    at a-addr and x1 at the next consecutive cell.
     It is equivalent to the sequence SWAP OVER !
    CELL+ !.

2*
    ( x1 -- x2 )
    x2 is the result of shifting x1 one bit toward
    the most-significant bit, filling the vacated
    least-significant bit with zero.

2/
    ( x1 -- x2 )
    x2 is the result of shifting x1 one bit toward
    the least-significant bit, leaving the
    most-significant bit unchanged.

2@
    ( a-addr -- x1 x2 )
    Fetch the cell pair x1 x2 stored at a-addr. 
    x2 is stored at a-addr and x1 at the next
    consecutive cell.  It is equivalent to the
    sequence DUP CELL+ @ SWAP @.

2DROP
    ( x1 x2 -- )
    Drop cell pair x1 x2 from the stack.

2DUP
    ( x1 x2 -- x1 x2 x1 x2 )
    Duplicate cell pair x1 x2.

2OVER
    ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 )
    Copy cell pair x1 x2 to the top of the stack.

2SWAP
    ( x1 x2 x3 x4 -- x3 x4 x1 x2 )
    Exchange the top two cell pairs.

:
    ( C: "<spaces>name" -- colon-sys )
    Skip leading space delimiters.  Parse name
    delimited by a space.  Create a definition for
    name, called a "colon definition".  Enter
    compilation state and start the current
    definition, producing colon-sys.  Append the
    initiation semantics given below to the
    current definition. The execution semantics of
    name will be determined by the words compiled
    into the body of the definition.  The current
    definition shall not be findable in the
    dictionary until it is ended (or until the
    execution of DOES> in some systems).
 S: ( i*x -- i*x )  ( R:  -- nest-sys )
    Save implementation-dependent information
    nest-sys about the calling definition.  The
    stack effects i*x represent arguments to name.
 E: name ( i*x -- j*x )
    Execute the definition name.  The stack effects
    i*x and j*x represent arguments to and results
    from name, respectively.

;
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: colon-sys -- )
    Append the run-time semantics below to the
    current definition.  End the current
    definition, allow it to be found in the
    dictionary and enter interpretation state,
    consuming colon-sys.  If the data-space
    pointer is not aligned, reserve enough data
    space to align it.
 R: ( -- )  ( R:  nest-sys -- )
    Return to the calling definition specified 
    by nest-sys.

<
    ( n1 n2 -- flag )
    flag is true if and only if n1 is less 
    than n2.

<#
    ( -- )
    Initialize the pictured numeric output 
    conversion process.

=
    ( x1 x2 -- flag )
    flag is true if and only if x1 is bit-for-bit 
    the same as x2.

>
    ( n1 n2 -- flag )
    flag is true if and only if n1 is greater 
    than n2.

>BODY
    ( xt -- a-addr )
    a-addr is the data-field address corresponding
    to xt.  An ambiguous condition exists if xt is
    not for a word defined via CREATE.

>IN
    ( -- a-addr )
    a-addr is the address of a cell containing the
    offset in characters from the start of the
    input buffer to the start of the parse area.

>NUMBER
    ( ud1 c-addr1 u1 -- ud2 c-addr2 u2 )
    ud2 is the unsigned result of converting the
    characters within the string specified by
    c-addr1 u1 into digits, using the number in
    BASE, and adding each into ud1 after
    multiplying ud1 by the number in BASE.
    Conversion continues left-to-right until a
    character that is not convertible, including
    any "+" or "-", is encountered or the string
    is entirely converted.  c-addr2 is the
    location of the first unconverted character or
    the first character past the end of the string
    if the string was entirely converted.  u2 is
    the number of unconverted characters in the
    string.  An ambiguous condition exists if ud2
    overflows during the conversion.

>R
 I: Interpretation semantics for this word are 
    undefined.
 E: ( x -- )  ( R:  -- x )
    Move x to the return stack.

?DUP
    ( x -- 0 | x x )
    Duplicate x if it is non-zero.

@
    ( a-addr -- x )
    x is the value stored at a-addr.

ABORT
    ( i*x -- ) ( R: j*x -- )
    Empty the data stack and perform the function
    of QUIT, which includes emptying the return
    stack, without displaying a message.

ABORT"
 I: Interpretation semantics for this word are 
    undefined.
 C: ( "ccc<quote>" -- )
    Parse ccc delimited by a " (double-quote). 
    Append the run-time semantics given below to
    the current definition.
 R: ( i*x x1 --  | i*x ) ( R: j*x --  | j*x )
    Remove x1 from the stack.  If any bit of x1 is
    not zero, display ccc and perform an
    implementation-defined abort sequence that
    includes the function of ABORT.

ABS
    ( n -- u )
    u is the absolute value of n.

ACCEPT
    ( c-addr +n1 -- +n2 )
    Receive a string of at most +n1 characters. 
    An ambiguous condition exists if +n1 is zero
    or greater than 32,767.  Display graphic
    characters as they are received.  A program
    that depends on the presence or absence of
    non-graphic characters in the string has an
    environmental dependency.  The editing
    functions, if any, that the system performs in
    order to construct the string are
    implementation-defined. Input terminates when
    an implementation-defined line terminator is
    received.  When input terminates, nothing is
    appended to the string, and the display is
    maintained in an implementation-defined way.
    +n2 is the length of the string stored at
    c-addr.

ALIGN
    ( -- )
    If the data-space pointer is not aligned,
    reserve enough space to align it.

ALIGNED
    ( addr -- a-addr )
    a-addr is the first aligned address greater
    than or equal to addr.

ALLOT
    ( n -- )
    If n is greater than zero, reserve n address
    units of data space.  If n is less than zero,
    release |n| address units of data space.  If n
    is zero, leave the data-space pointer
    unchanged. If the data-space pointer is
    aligned and n is a multiple of the size of a
    cell when ALLOT begins execution, it will
    remain aligned when ALLOT finishes execution.
    If the data-space pointer is character aligned
    and n is a multiple of the size of a character
    when ALLOT begins execution, it will remain
    character aligned when ALLOT finishes
    execution.

AND
    ( x1 x2 -- x3 )
    x3 is the bit-by-bit logical "and" of x1 
    with x2.

BASE
    ( -- a-addr )
    a-addr is the address of a cell containing the
    current number-conversion radix {{2...36}}

BEGIN
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: -- dest )
    Put the next location for a transfer of
    control, dest, onto the control flow stack. 
    Append the run-time semantics given below to
    the current definition.
 R: ( -- )
    Continue execution.

BL
    ( -- char )
    char is the character value for a space.

C!
    ( char c-addr -- )
    Store char at c-addr.  When character size is
    smaller than cell size, only the number of
    low-order bits corresponding to character size
    are transferred.

C,
    ( char -- )
    Reserve space for one character in the data
    space and store char in the space.  If the
    data-space pointer is character aligned when
    C, begins execution, it will remain character
    aligned when C, finishes execution. An
    ambiguous condition exists if the data-space
    pointer is not character-aligned prior to
    execution of C,.

C@
    ( c-addr -- char )
    Fetch the character stored at c-addr.  When the
    cell size is greater than character size, the
    unused high-order bits are all zeroes.

CELL+
    ( a-addr1 -- a-addr2 )
    Add the size in address units of a cell to
    a-addr1, giving a-addr2.

CELLS
    ( n1 -- n2 )
    n2 is the size in address units of n1 cells.

CHAR
    ( "<spaces>name" -- char )
    Skip leading space delimiters.  Parse name
    delimited by a space.  Put the value of its
    first character onto the stack.

CHAR+
    ( c-addr1 -- c-addr2 )
    Add the size in address units of a character
    to c-addr1, giving c-addr2.

CHARS
    ( n1 -- n2 )
    n2 is the size in address units of n1
    characters.

CONSTANT
    ( x "<spaces>name" -- )
    Skip leading space delimiters.  Parse name
    delimited by a space.  Create a definition for
    name with the execution semantics defined
    below. name is referred to as a "constant".
 E: name ( -- x )
    Place x on the stack.

COUNT
    ( c-addr1 -- c-addr2 u )
    Return the character string specification for
    the counted string stored at c-addr1.  c-addr2
    is the address of the first character after
    c-addr1.  u is the contents of the character
    at c-addr1, which is the length in characters
    of the string at c-addr2.

CR
    ( -- )
    Cause subsequent output to appear at the 
    beginning of the next line.

CREATE
    ( "<spaces>name" -- )
    Skip leading space delimiters.  Parse name
    delimited by a space.  Create a definition for
    name with the execution semantics defined
    below.  If the data-space pointer is not
    aligned, reserve enough data space to align
    it.  The new data-space pointer defines name's
    data field.  CREATE does not allocate data
    space in name's data field.
 E: name ( -- a-addr )
    a-addr is the address of name's data field. 
    The execution semantics of name may be
    extended by using DOES>.

DECIMAL
    ( -- )
    Set the numeric conversion radix to ten 
    (decimal).

DEPTH
    ( -- +n )
    +n is the number of single-cell values
    contained in the data stack before +n was
    placed on the stack.

DO
 I: Interpretation semantics for this word 
    are undefined.
 C: ( C: -- do-sys )
    Place do-sys onto the control-flow stack. 
    Append the run-time semantics given below to
    the current definition.  The semantics are
    incomplete until resolved by a consumer of
    do-sys such as LOOP.
 R: ( n1|u1 n2|u2 -- ) ( R: -- loop-sys )
    Set up loop control parameters with index n2|u2
    and limit n1|u1. An ambiguous condition exists
    if n1|u1 and n2|u2 are not both the same type.
     Anything already on the return stack becomes
    unavailable until the loop-control parameters
    are discarded.

DOES>
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: colon-sys1 -- colon-sys2 )
    Append the run-time semantics below to the
    current definition.  Whether or not the
    current definition is rendered findable in the
    dictionary by the compilation of DOES> is
    implementation defined.  Consume colon-sys1
    and produce colon-sys2.  Append the initiation
    semantics given below to the current
    definition.
 R: ( -- ) ( R: nest-sys1 -- )
    Replace the execution semantics of the most
    recent definition, referred to as name, with
    the name execution semantics given below. 
    Return control to the calling definition
    specified by nest-sys1.  An ambiguous
    condition exists if name was not defined with
    CREATE or a user-defined word that calls
    CREATE.
 S: ( i*x -- i*x a-addr )  ( R:  -- nest-sys2 )
    Save implementation-dependent information
    nest-sys2 about the calling definition.  Place
    name's data field address on the stack.  The
    stack effects i*x represent arguments to name.
 E: name ( i*x -- j*x )
    Execute the portion of the definition that
    begins with the initiation semantics appended
    by the DOES> which modified name.  The stack
    effects i*x and j*x represent arguments to and
    results from name, respectively.

DROP
    ( x -- )
    Remove x from the stack.

DUP
    ( x -- x x )
    Duplicate x.

ELSE

 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: orig1 -- orig2 )
    Put the location of a new unresolved forward
    reference orig2 onto the control flow stack. 
    Append the run-time semantics given below to
    the current definition.  The semantics will be
    incomplete until orig2 is resolved (e.g., by
    THEN).  Resolve the forward reference orig1
    using the location following the appended 
    run-time semantics.
 R: ( -- )
    Continue execution at the location given by 
    the resolution of orig2.

EMIT
    ( x -- )
    If x is a graphic character in the
    implementation-defined character set, display
    x.  The effect of EMIT for all other values of
    x is implementation-defined. When passed a
    character whose character-defining bits have a
    value between hex 20 and 7E inclusive, the
    corresponding standard character, specified by
    3.1.2.1 Graphic characters, is displayed. 
    Because different output devices can respond
    differently to control characters, programs
    that use control characters to perform
    specific functions have an environmental
    dependency.  Each EMIT deals with only one
    character.

ENVIRONMENT?
    ( c-addr u -- false | i*x true )
    c-addr is the address of a character string and
    u is the string's character count.  u may have
    a value in the range from zero to an
    implementation-defined maximum which shall not
    be less than 31.  The character string should
    contain a keyword from 3.2.6 Environmental
    queries or the optional word sets to be
    checked for correspondence with an attribute
    of the present environment.  If the system
    treats the attribute as unknown, the returned
    flag is false;  otherwise, the flag is true
    and the i*x returned is of the type specified
    in the table for the attribute queried.

EVALUATE
    ( i*x c-addr u -- j*x )
    Save the current input source specification. 
    Store minus-one (-1) in SOURCE-ID if it is
    present.  Make the string described by c-addr
    and u both the input source and input buffer,
    set >IN to zero, and interpret. When the parse
    area is empty, restore the prior input source
    specification.  Other stack effects are due to
    the words EVALUATEd.

EXECUTE
    ( i*x xt -- j*x )
    Remove xt from the stack and perform the
    semantics identified by it. Other stack
    effects are due to the word EXECUTEd.

EXIT
 I: Interpretation semantics for this word are 
    undefined.
 E: ( -- ) ( R: nest-sys -- )
    Return control to the calling definition
    specified by nest-sys.  Before executing EXIT
    within a do-loop, a program shall discard the
    loop- control parameters by executing UNLOOP.

FILL
    ( c-addr u char -- )
    If u is greater than zero, store char in each
    of u consecutive characters of memory
    beginning at c-addr.

FIND
    ( c-addr -- c-addr 0  |  xt 1  |  xt -1 )
    Find the definition named in the counted string
    at c-addr.  If the definition is not found,
    return c-addr and zero.  If the definition is
    found, return its execution token xt.  If the
    definition is immediate, also return one (1),
    otherwise also return minus-one (-1).  For a
    given string, the values returned by FIND
    while compiling may differ from those returned
    while not compiling.

FM/MOD
    ( d1 n1 -- n2 n3 )
    Divide d1 by n1, giving the floored quotient
    n3 and the remainder n2. Input and output
    stack arguments are signed.  An ambiguous
    condition exists if n1 is zero or if the
    quotient lies outside the range of a
    single-cell signed integer.

HERE
    ( -- addr )
    addr is the data-space pointer.

HOLD
    ( char -- )
    Add char to the beginning of the pictured
    numeric output string.  An ambiguous condition
    exists if HOLD executes outside of a <# #>
    delimited number conversion.

I
 I: Interpretation semantics for this word are 
    undefined.
 E: ( -- n|u )  ( R:  loop-sys -- loop-sys )
    n|u is a copy of the current (innermost) loop
    index.  An ambiguous condition exists if the
    loop control parameters are unavailable.

IF
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: -- orig )
    Put the location of a new unresolved forward
    reference orig onto the control flow stack.
    Append the run-time semantics given below to
    the current definition.  The semantics are
    incomplete until orig is resolved, e.g., by
    THEN or ELSE.
 R: ( x -- )
    If all bits of x are zero, continue execution
    at the location specified by the resolution of
    orig.

IMMEDIATE
    ( -- )
    Make the most recent definition an immediate
    word.  An ambiguous condition exists if the
    most recent definition does not have a name.

INVERT
    ( x1 -- x2 )
    Invert all bits of x1, giving its logical 
    inverse x2.

J
 I: Interpretation semantics for this word are 
    undefined.
 E: ( -- n|u ) ( R: loop-sys1 loop-sys2 -- loop-sys1 loop-sys2 )
    n|u is a copy of the next-outer loop index. 
    An ambiguous condition exists if the loop
    control parameters of the next-outer loop,
    loop-sys1, are unavailable.

KEY
    ( -- char )
    Receive one character char, a member of the
    implementation-defined character set. 
    Keyboard events that do not correspond to such
    characters are discarded until a valid
    character is received, and those events are
    subsequently unavailable. All standard
    characters can be received.  Characters
    received by KEY are not displayed. Any
    standard character returned by KEY has the
    numeric value specified in 3.1.2.1 Graphic
    characters.  Programs that require the ability
    to receive control characters have an
    environmental dependency.

LEAVE
 I: Interpretation semantics for this word are 
    undefined.
 E: ( -- )  ( R: loop-sys -- )
    Discard the current loop control parameters. 
    An ambiguous condition exists if they are
    unavailable.  Continue execution immediately
    following the innermost syntactically
    enclosing DO ... LOOP or DO ... +LOOP.

LITERAL
 I: Interpretation semantics for this word are 
    undefined.
 C: ( x -- )
    Append the run-time semantics given below 
    to the current definition.
 R: ( -- x )
    Place x on the stack.

LOOP
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: do-sys -- )
    Append the run-time semantics given below to
    the current definition. Resolve the
    destination of all unresolved occurrences of
    LEAVE between the location given by do-sys and
    the next location for a transfer of control,
    to execute the words following the LOOP.
 R: ( -- )  ( R:  loop-sys1 --  | loop-sys2 )
    An ambiguous condition exists if the loop
    control parameters are unavailable.  Add one
    to the loop index.  If the loop index is then
    equal to the loop limit, discard the loop
    parameters and continue execution immediately
    following the loop.  Otherwise continue
    execution at the beginning of the loop.

LSHIFT
    ( x1 u -- x2 )
    Perform a logical left shift of u bit-places
    on x1, giving x2.  Put zeroes into the least
    significant bits vacated by the shift.  An
    ambiguous condition exists if u is greater
    than or equal to the number of bits in a cell.

M*
    ( n1 n2 -- d )
    d is the signed product of n1 times n2.

MAX
    ( n1 n2 -- n3 )
    n3 is the greater of n1 and n2.

MIN
    ( n1 n2 -- n3 )
    n3 is the lesser of n1 and n2.

MOD
    ( n1 n2 -- n3 )
    Divide n1 by n2, giving the single-cell
    remainder n3.  An ambiguous condition exists
    if n2 is zero.  If n1 and n2 differ in sign,
    the implementation-defined result returned
    will be the same as that returned by either
    the phrase >R S>D R> FM/MOD DROP or the phrase
    >R S>D R> SM/REM DROP.

MOVE
    ( addr1 addr2 u -- )
    If u is greater than zero, copy the contents
    of u consecutive address units at addr1 to the
    u consecutive address units at addr2.  After
    MOVE completes, the u consecutive address
    units at addr2 contain exactly what the u
    consecutive address units at addr1 contained
    before the move.

NEGATE
    ( n1 -- n2 )
    Negate n1, giving its arithmetic inverse n2.

OR
    ( x1 x2 -- x3 )
    x3 is the bit-by-bit inclusive-or of x1 
    with x2.

OVER
    ( x1 x2 -- x1 x2 x1 )
    Place a copy of x1 on top of the stack.

POSTPONE
 I: Interpretation semantics for this word are 
    undefined.
 C: ( "<spaces>name" -- )
    Skip leading space delimiters.  Parse name
    delimited by a space.  Find name.  Append the
    compilation semantics of name to the current
    definition.  An ambiguous condition exists if
    name is not found.

QUIT
    ( -- )  ( R:  i*x -- )
    Empty the return stack, store zero in SOURCE-ID
    if it is present, make the user input device
    the input source, and enter interpretation
    state. Do not display a message.  Repeat
    ACCEPT input, EVALUATE it and TYPE the result
    if in interpretation state, all processing has
    been completed and no ambiguous condition
    exists.

R>
 I: Interpretation semantics for this word are 
    undefined.
 E: ( -- x )  ( R:  x -- )
    Move x from the return stack to the data stack.

R@
 I: Interpretation semantics for this word are 
    undefined.
 E: ( -- x )  ( R:  x -- x )
    Copy x from the return stack to the data stack.

RECURSE
 I: Interpretation semantics for this word are 
    undefined.
 C: ( -- )
    Append the execution semantics of the current
    definition to the current definition.  An
    ambiguous condition exists if RECURSE appears
    in a definition after DOES>.

REPEAT
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: orig dest -- )
    Append the run-time semantics given below to
    the current definition, resolving the backward
    reference dest.  Resolve the forward reference
    orig using the location following the appended
    run-time semantics.
 R: ( -- )
    Continue execution at the location given by dest.

ROT
    ( x1 x2 x3 -- x2 x3 x1 )
    Rotate the top three stack entries.

RSHIFT
    ( x1 u -- x2 )
    Perform a logical right shift of u bit-places
    on x1, giving x2.  Put zeroes into the most
    significant bits vacated by the shift.  An
    ambiguous condition exists if u is greater
    than or equal to the number of bits in a cell.

S
 I: Interpretation semantics for this word are 
    undefined.
 C: ( "ccc<quote>" -- )
    Parse ccc delimited by " (double-quote). 
    Append the run-time semantics given below to
    the current definition.
 R: ( -- c-addr u )
    Return c-addr and u describing a string
    consisting of the characters ccc.  A program
    shall not alter the returned string.

S>D
    ( n -- d )
    Convert the number n to the double-cell number
    d with the same numerical value.

SIGN
    ( n -- )
    If n is negative, add a minus sign to the
    beginning of the pictured numeric output
    string.  An ambiguous condition exists if SIGN
    executes outside of a <# #> delimited number
    conversion.

SM/REM
    ( d1 n1 -- n2 n3 )
    Divide d1 by n1, giving the symmetric quotient
    n3 and the remainder n2. Input and output
    stack arguments are signed.  An ambiguous
    condition exists if n1 is zero or if the
    quotient lies outside the range of a
    single-cell signed integer.

SOURCE
    ( -- c-addr u )
    c-addr is the address of, and u is the number
    of characters in, the input buffer.

SPACE
    ( -- )
    Display one space.

SPACES
    ( n -- )
    If n is greater than zero, display n spaces.

STATE
    ( -- a-addr )
    a-addr is the address of a cell containing the
    compilation-state flag. STATE is true when in
    compilation state, false otherwise.  The true
    value in STATE is non-zero, but is otherwise
    implementation-defined. Only the following
    standard words alter the value in STATE: :
    (colon), ; (semicolon), ABORT, QUIT, :NONAME,
    [ (left-bracket), and ] (right- bracket).
 N: A program shall not directly alter the contents 
    of STATE.

SWAP
    ( x1 x2 -- x2 x1 )
    Exchange the top two stack items.

THEN
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: orig -- )
    Append the run-time semantics given below to
    the current definition. Resolve the forward
    reference orig using the location of the
    appended run-time semantics.
 R: ( -- )
    Continue execution.

TYPE
    ( c-addr u -- )
    If u is greater than zero, display the
    character string specified by c- addr and u.
    When passed a character in a character string
    whose character-defining bits have a value
    between hex 20 and 7E inclusive, the
    corresponding standard character, specified by
    3.1.2.1 graphic characters, is displayed. 
    Because different output devices can respond
    differently to control characters, programs
    that use control characters to perform
    specific functions have an environmental
    dependency.

U.
    ( u -- )
    Display u in free field format.

U<
    ( u1 u2 -- flag )
    flag is true if and only if u1 is less than u2.

UM*
    ( u1 u2 -- ud )
    Multiply u1 by u2, giving the unsigned
    double-cell product ud. All values and
    arithmetic are unsigned.

UM/MOD
    ( ud u1 -- u2 u3 )
    Divide ud by u1, giving the quotient u3 and the
    remainder u2.  All values and arithmetic are
    unsigned.  An ambiguous condition exists if u1
    is zero or if the quotient lies outside the
    range of a single-cell unsigned integer.

UNLOOP
 I: Interpretation semantics for this word are 
    undefined.
 E: ( -- ) ( R: loop-sys -- )
    Discard the loop-control parameters for the
    current nesting level.  An UNLOOP is required
    for each nesting level before the definition
    may be EXITed.  An ambiguous condition exists
    if the loop-control parameters are
    unavailable.

UNTIL
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: dest -- )
    Append the run-time semantics given below to
    the current definition, resolving the backward
    reference dest.
 R: ( x -- )
    If all bits of x are zero, continue execution
    at the location specified by dest.

VARIABLE
    ( "<spaces>name" -- )
    Skip leading space delimiters.  Parse name
    delimited by a space.  Create a definition for
    name with the execution semantics defined
    below. Reserve one cell of data space at an
    aligned address. name is referred to as a
 E: name ( -- a-addr )
    a-addr is the address of the reserved cell.  A
    program is responsible or initializing the
    contents of the reserved cell.

WHILE
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: dest -- orig dest )
    Put the location of a new unresolved forward
    reference orig onto the control flow stack,
    under the existing dest.  Append the run-time
    semantics given below to the current
    definition.  The semantics are incomplete
    until orig and dest are resolved (e.g., by
    REPEAT).
 R: ( x -- )
    If all bits of x are zero, continue execution
    at the location specified by the resolution of
    orig.

WORD
    ( char "<chars>ccc<char>" -- c-addr )
    Skip leading delimiters.  Parse characters ccc
    delimited by char.  An ambiguous condition
    exists if the length of the parsed string is
    greater than the implementation-defined length
    of a counted string. c-addr is the address of
    a transient region containing the parsed word
    as a counted string.  If the parse area was
    empty or contained no characters other than
    the delimiter, the resulting string has a zero
    length.  A space, not included in the length,
    follows the string.  A program may replace
    characters within the string.
 N: The requirement to follow the string with a
    space is obsolescent and is included as a
    concession to existing programs that use
    CONVERT.  A program shall not depend on the
    existence of the space.

XOR
    ( x1 x2 -- x3 )
    x3 is the bit-by-bit exclusive-or of x1 with x2.

[
 I: Interpretation semantics for this word are 
    undefined.
 C: Perform the execution semantics given below.
 E: ( -- )
    Enter interpretation state.  [ is an immediate 
    word.

[']
 I: Interpretation semantics for this word are 
    undefined.
 C: ( "<spaces>name" -- )
    Skip leading space delimiters.  Parse name
    delimited by a space.  Find name.  Append the
    run-time semantics given below to the current
    definition. An ambiguous condition exists if
    name is not found.
 R: ( -- xt )
    Place name's execution token xt on the stack. 
    The execution token returned by the compiled
    phrase "['] X " is the same value returned by
    "' X " outside of compilation state.

[CHAR]
 I: Interpretation semantics for this word are 
    undefined.
 C: ( "<spaces>name" -- )
    Skip leading space delimiters.  Parse name
    delimited by a space.  Append the run-time
    semantics given below to the current
    definition.
 R: ( -- char )
    Place char, the value of the first character 
    of name, on the stack.

]
    ( -- )
    Enter compilation state.



Core extension words


#TIB
    ( -- a-addr )
    a-addr is the address of a cell containing the
    number of characters in the terminal input
    buffer.
 N: This word is obsolescent and is included as a 
    concession to existing implementations.

.(
 C: Perform the execution semantics given below.
 E: ( "ccc<paren>" -- )
    Parse and display ccc delimited by ) (right
    parenthesis).  .( is an immediate word.

.R
    ( n1 n2 -- )
    Display n1 right aligned in a field n2
    characters wide.  If the number of characters
    required to display n1 is greater than n2, all
    digits are displayed with no leading spaces in
    a field as wide as necessary.

0<>
    ( x -- flag )
    flag is true if and only if x is not equal 
    to zero.

0>
    ( n -- flag )
    flag is true if and only if n is greater than 
    zero.

2>R
 I: Interpretation semantics for this word are 
    undefined.
 E: ( x1 x2 -- ) ( R:  -- x1 x2 )
    Transfer cell pair x1 x2 to the return stack.  
    Semantically equivalent to SWAP >R >R.

2R>
 I: Interpretation semantics for this word are 
    undefined.
 E: ( -- x1 x2 )  ( R:  x1 x2 -- )
    Transfer cell pair x1 x2 from the return stack.
     Semantically equivalent to R> R> SWAP.

2R@
 I: Interpretation semantics for this word are 
    undefined.
 E: ( -- x1 x2 )  ( R:  x1 x2 -- x1 x2 )
    Copy cell pair x1 x2 from the return stack. 
    Semantically equivalent to R> R> 2DUP >R >R
    SWAP.

:NONAME
    ( C:  -- colon-sys )  ( S:  -- xt )
    Create an execution token xt, enter compilation
    state and start the current definition,
    producing colon-sys.  Append the initiation
    semantics given below to the current
    definition. The execution semantics of xt will
    be determined by the words compiled into the
    body of the definition.  This definition can
    be executed later by using xt EXECUTE. If the
    control-flow stack is implemented using the
    data stack, colon-sys shall be the topmost
    item on the data stack.
 S: ( i*x -- i*x )  ( R:  -- nest-sys )
    Save implementation-dependent information
    nest-sys about the calling definition.  The
    stack effects i*x represent arguments to xt.
 E: xt ( i*x -- j*x )
    Execute the definition specified by xt.  The
    stack effects i*x and j*x represent arguments
    to and results from xt, respectively.

<>
    ( x1 x2 -- flag )
    flag is true if and only if x1 is not 
    bit-for-bit the same as x2.

?DO
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: -- do-sys )
    Put do-sys onto the control-flow stack.  Append
    the run-time semantics given below to the
    current definition.  The semantics are
    incomplete until resolved by a consumer of
    do-sys such as LOOP.
 R: ( n1|u1 n2|u2 -- ) ( R: --  | loop-sys )
    If n1|u1 is equal to n2|u2, continue execution
    at the location given by the consumer of
    do-sys.  Otherwise set up loop control
    parameters with index n2|u2 and limit n1|u1
    and continue executing immediately following
    ?DO.  Anything already on the return stack
    becomes unavailable until the loop control
    parameters are discarded.  An ambiguous
    condition exists if n1|u1 and n2|u2 are not
    both of the same type.

AGAIN

 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: dest -- )
    Append the run-time semantics given below to
    the current definition, resolving the backward
    reference dest.
 R: ( -- )
    Continue execution at the location specified
    by dest.  If no other control flow words are
    used, any program code after AGAIN will not be
    executed.

C
 I: Interpretation semantics for this word are 
    undefined.
 C: ( "ccc<quote>" -- )
    Parse ccc delimited by " (double-quote) and
    append the run-time semantics given below to
    the current definition.
 R: ( -- c-addr )
    Return c-addr, a counted string consisting of
    the characters ccc.  A program shall not alter
    the returned string.

CASE
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: -- case-sys )
    Mark the start of the CASE ... OF ... ENDOF ...
    ENDCASE  structure. Append the run-time
    semantics given below to the current
    definition.
 R: ( -- )
    Continue execution.

COMPILE,
 I: Interpretation semantics for this word are 
    undefined.
 E: ( xt -- )
    Append the execution semantics of the
    definition represented by xt to the execution
    semantics of the current definition.

CONVERT
    ( ud1 c-addr1 -- ud2 c-addr2 )
    ud2 is the result of converting the characters
    within the text beginning at the first
    character after c-addr1 into digits, using the
    number in BASE, and adding each digit to ud1
    after multiplying ud1 by the number in BASE. 
    Conversion continues until a character that is
    not convertible is encountered.  c-addr2 is
    the location of the first unconverted
    character.  An ambiguous condition exists if
    ud2 overflows. 
 N: This word is obsolescent and is included as
    a concession to existing implementations.  Its
    function is superseded by 6.1.0570 >NUMBER.

ENDCASE
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: case-sys -- )
    Mark the end of the CASE ... OF ... ENDOF ...
    ENDCASE structure.  Use case-sys to resolve
    the entire structure.  Append the run-time
    semantics given below to the current
    definition.
 R: ( x -- )
    Discard the case selector x and continue 
    execution.

ENDOF
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: case-sys1 of-sys -- case-sys2 )
    Mark the end of the OF ... ENDOF part of the
    CASE structure.  The next location for a
    transfer of control resolves the reference
    given by of-sys.  Append the run-time
    semantics given below to the current
    definition.  Replace case-sys1 with case-sys2
    on the control-flow stack, to be resolved by
    ENDCASE.
 R: ( -- )
    Continue execution at the location specified
    by the consumer of case-sys2.

ERASE
    ( addr u -- )
    If u is greater than zero, clear all bits in
    each of u consecutive address units of memory
    beginning at addr .

EXPECT
    ( c-addr +n -- )
    Receive a string of at most +n characters. 
    Display graphic characters as they are
    received.  A program that depends on the
    presence or absence of non-graphic characters
    in the string has an environmental dependency.
    The editing functions, if any, that the system
    performs in order to construct the string of
    characters are implementation-defined. Input
    terminates when an implementation-defined line
    terminator is received or when the string is
    +n characters long.  When input terminates,
    nothing is appended to the string and the
    display is maintained in an
    implementation-defined way. Store the string
    at c-addr and its length in SPAN.
 N: This word is obsolescent and is included as
    a concession to existing implementations.  Its
    function is superseded by 6.1.0695 ACCEPT.

FALSE
    ( -- false )
    Return a false flag.

HEX
    ( -- )
    Set contents of BASE to sixteen.

MARKER
    ( "<spaces>name" -- )
    Skip leading space delimiters.  Parse name
    delimited by a space.  Create a definition for
    name with the execution semantics defined
    below.
 E: name ( -- )
    Restore all dictionary allocation and search
    order pointers to the state they had just
    prior to the definition of name.  Remove the
    definition of name and all subsequent
    definitions.  Restoration of any structures
    still existing that could refer to deleted
    definitions or deallocated data space is not
    necessarily provided.  No other contextual
    information such as numeric base is affected.

NIP
    ( x1 x2 -- x2 )
    Drop the first item below the top of stack.

OF
 I: Interpretation semantics for this word are 
    undefined.
 C: ( C: -- of-sys )
    Put of-sys onto the control flow stack.  Append
    the run-time semantics given below to the
    current definition.  The semantics are
    incomplete until resolved by a consumer of
    of-sys such as ENDOF.
 R: ( x1 x2 --   | x1 )
    If the two values on the stack are not equal,
    discard the top value and continue execution
    at the location specified by the consumer of
    of-sys, e.g., following the next ENDOF. 
    Otherwise, discard both values and continue
    execution in line.

PAD
    ( -- c-addr )
    c-addr is the address of a transient region
    that can be used to hold data for intermediate
    processing.

PARSE
    ( char "ccc<char>" -- c-addr u )
    Parse ccc delimited by the delimiter char.
    c-addr is the address (within the input
    buffer) and u is the length of the parsed
    string.  If the parse area was empty, the
    resulting string has a zero length.

PICK
    ( xu ... x1 x0 u -- xu ... x1 x0 xu )
    Remove u.  Copy the xu to the top of the stack.
    An ambiguous condition exists if there are
    less than u+2 items on the stack before PICK
    is executed.

QUERY
    ( -- )
    Make the user input device the input source. 
    Receive input into the terminal input buffer,
    replacing any previous contents.  Make the
    result, whose address is returned by TIB, the
    input buffer.  Set >IN to zero.
 N: This word is obsolescent and is included as
    a concession to existing implementations.

REFILL
    ( -- flag )
    Attempt to fill the input buffer from the input
    source, returning a true flag if successful.
    When the input source is the user input
    device, attempt to receive input into the
    terminal input buffer.  If successful, make
    the result the input buffer, set >IN to zero,
    and return true.  Receipt of a line containing
    no characters is considered successful.  If
    there is no input available from the current
    input source, return false. When the input
    source is a string from EVALUATE, return false
    and perform no other action.

RESTORE-INPUT
    ( xn ... x1 n -- flag )
    Attempt to restore the input source
    specification to the state described by x1
    through xn.  flag is true if the input source
    specification cannot be so restored. An
    ambiguous condition exists if the input source
    represented by the arguments is not the same
    as the current input source.

ROLL
    ( xu xu-1 ... x0 u -- xu-1 ... x0 xu )
    Remove u.  Rotate u+1 items on the top of the
    stack.  An ambiguous condition exists if there
    are less than u+2 items on the stack before
    ROLL is executed.

SAVE-INPUT
    ( -- xn ... x1 n )
    x1 through xn describe the current state of the
    input source specification for later use by
    RESTORE-INPUT.

SOURCE-ID
    ( -- 0 | -1 )
    Identifies the input source. -1 is a String via
    EVALUATE, 0 is input by the user.

SPAN
    ( -- a-addr )
    a-addr is the address of a cell containing the
    count of characters stored by the last
    execution of EXPECT.
 N: This word is obsolescent and is included as
    a concession to existing implementations.

TIB
    ( -- c-addr )
    c-addr is the address of the terminal input 
    buffer.
 N: This word is obsolescent and is included as a 
    concession to existing implementations.

TO
 I: ( x "<spaces>name" -- )
	Skip leading spaces and parse name delimited
	by a space.  Store x in name.  An ambiguous
	condition exists if name was not defined by
	VALUE.
 C: ( "<spaces>name" -- )
	Skip leading spaces and parse name delimited
	by a space.  Append the run-time semantics
	given below to the current definition.  An
	ambiguous condition exists if name was not
	defined by VALUE.
 R: ( x -- )
    Store x in name.
 N: An ambiguous condition exists if either
	POSTPONE or [COMPILE] is applied to TO.

TRUE
    ( -- true )
    Return a true flag, a single-cell value 
    with all bits set.

TUCK
    ( x1 x2 -- x2 x1 x2 )
    Copy the first (top) stack item below the 
    second stack item.

U.R
    ( u n -- )
	Display u right aligned in a field n characters
	wide.  If the number of characters required to
	display u is greater than n, all digits are
	displayed with no leading spaces in a field as
	wide as necessary.

U>
    ( u1 u2 -- flag )
    flag is true if and only if u1 is greater 
    than u2.

UNUSED
    ( -- u )
	u is the amount of space remaining in the
	region addressed by HERE, in address units.

VALUE
    ( x "<spaces>name" -- )
	Skip leading space delimiters.  Parse name
	delimited by a space.  Create a definition for
	name with the execution semantics defined
	below, with an initial value equal to x. name
	is referred to as a "value".
 E: name ( -- x )
	Place x on the stack.  The value of x is that
	given when name was created, until the phrase
	x TO name is executed, causing a new value of
	x to be associated with name.

WITHIN
    ( n1|u1 n2|u2 n3|u3 -- flag )
	Perform a comparison of a test value n1|u1 with
	a lower limit n2|u2 and an upper limit n3|u3,
	returning true if either (n2|u2 < n3|u3 and
	(n2|u2 <= n1|u1 and n1|u1 < n3|u3)) or (n2|u2
	> n3|u3 and (n2|u2 <= n1|u1 or n1|u1 < n3|u3))
	is true, returning false otherwise.  An
	ambiguous condition exists if n1|u1, n2|u2,
	and n3|u3 are not all the same type.

[COMPILE]
 I: Interpretation semantics for this word are 
    undefined.
 C: ( "<spaces>name" -- )
	Skip leading space delimiters.  Parse name
	delimited by a space.  Find name.  If name has
	other than default compilation semantics,
	append them to the current definition;
	otherwise append the execution semantics of
	name.  An ambiguous condition exists if name
	is not found.

\
 C: Perform the execution semantics given below.
 E: ( "ccc<eol>"-- )
	Parse and discard the remainder of the parse
	area.  \ is an immediate word.
	
